const Router = require("koa-router");
//自定义中间件
const {
    userValidator,
    verifyUser,
    crpytPassword,
    verifyLogin,
} = require("../middleware/user.middleware");

const {auth} = require("../middleware/auth.middleware");
const { register, login, changePassword } = require("../controller/user.controller");
//实例化对象
const router = new Router({ prefix: "/users" });

//把请求交给控制器里的函数来处理
//注册接口
router.post("/register", userValidator, verifyUser, crpytPassword, register);
//登录接口
router.post("/login", userValidator, verifyLogin, login);
//修改密码
router.patch('/', auth, crpytPassword, changePassword);

//注册中间件
module.exports = router;
